package com.luying.controller.controller;


import com.luying.pojo.PageQuery;
import com.luying.pojo.Result;
import com.luying.pojo.TeacherJobInformation;
import com.luying.pojo.User;
import com.luying.service.TeacherJobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 教师工作信息controller
 */
@RestController
@RequestMapping("/job")
public class TeacherJobController {
    @Autowired
    private TeacherJobService teacherJobService;

    @PostMapping("/add")
    public Result add(@RequestBody TeacherJobInformation job) {
        try {
            return Result.ok(teacherJobService.add(job));
        } catch (Exception e) {
           return Result.error(e.getMessage());
        }
    }

    @PostMapping("/update")
    public Result update(@RequestBody TeacherJobInformation job) {
        try {
            return Result.ok(teacherJobService.add(job));
        } catch (Exception e) {
           return Result.error(e.getMessage());
        }
    }

    @PostMapping("/query")
    public Result query(@RequestBody PageQuery pageQuery){
        return Result.ok(teacherJobService.query(pageQuery));
    }

    /**
     * 教师用户下拉
     * @return
     */
    @GetMapping("/teacher/list")
    public Result teacherList(){
        return Result.ok(teacherJobService.teacherList());
    }
    /**
     * 班级下拉
     * @return
     */
    @GetMapping("/class/list")
    public Result classList(){
        return Result.ok(teacherJobService.classList());
    }

    /**
     * 科目下拉
     * @return
     */
    @GetMapping("/subject/list")
    public Result subjectList(@RequestParam(name="id")Integer id){
        return Result.ok(teacherJobService.subjectList(id));
    }
}
